package com.sjd.wx.config;

import com.sjd.wx.interceptor.ThirdSessionInterceptor;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * web配置
 *
 * @author joker
 */
@Configuration
@AllArgsConstructor
public class WebConfig implements WebMvcConfigurer {
    private final RedisTemplate<Object, Object> redisTemplate;

    /**
     * 拦截器
     *
     * @param registry registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        /*
          进入ThirdSession拦截器
         */
        registry.addInterceptor(new ThirdSessionInterceptor(redisTemplate))
                //拦截/api/**接口
                .addPathPatterns("/weixin/api/**")
                //放行接口
                .excludePathPatterns("/weixin/api/ma/wxuser/login","/weixin/api/ma/goldenbean/payResultNotify","/weixin/api/ma/demo/*");

    }
}
